import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

export const store = new Vuex.Store({
    state: {
        count: 50
    },
    getters: {
        addCount(state) {
            return state.count + 100;
        }
    },
    mutations: {
        handleCount(state, num) {
            console.log(this)
            state.count += num;
        }
    },
    actions: {
        asynCount(context, num){
            setTimeout(() => {
                context.commit('handleCount', num);
            }, 1000)
            
        }
    }
})